package o;

import java.io.IOException;
import java.net.Proxy;
import java.net.ProxySelector;
import java.net.Socket;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;
import javax.net.SocketFactory;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import o.fuf.d;
import o.fum.a;
import okhttp3.RealCall;
import okhttp3.Route;
import okhttp3.internal.connection.RealConnection;
import okhttp3.internal.connection.StreamAllocation;

public class fuv implements Cloneable, o.ftz.e {
    static final List<fut> ˏ = fvg.ˋ(fut.HTTP_2, fut.HTTP_1_1);
    static final List<fud> ॱ = fvg.ˋ(fud.ˏ, fud.ˎ);
    final List<fuo> ʻ;
    final ftx ʻॱ;
    final a ʼ;
    final fuj ʼॱ;
    final List<fud> ʽ;
    final boolean ʽॱ;
    final fuf ʾ;
    final boolean ʿ;
    final boolean ˈ;
    final int ˉ;
    final List<fut> ˊ;
    final int ˊˊ;
    final int ˊˋ;
    final SocketFactory ˊॱ;
    final int ˊᐝ;
    @Nullable
    final Proxy ˋ;
    final int ˋˊ;
    final int ˋˋ;
    @Nullable
    final ftw ˋॱ;
    final ful ˎ;
    final e ˎˎ;
    final SSLSocketFactory ˏॱ;
    final fue ͺ;
    @Nullable
    final fvj ॱˊ;
    final fxe ॱˋ;
    final ftx ॱˎ;
    final List<fuo> ॱॱ;
    final fty ॱᐝ;
    final ProxySelector ᐝ;
    final HostnameVerifier ᐝॱ;

    public static final class b {
        ProxySelector ʻ;
        ftx ʻॱ;
        @Nullable
        ftw ʼ;
        boolean ʼॱ;
        final List<fuo> ʽ;
        boolean ʽॱ;
        int ʾ;
        boolean ʿ;
        int ˈ;
        int ˉ;
        @Nullable
        Proxy ˊ;
        int ˊˊ;
        int ˊˋ;
        @Nullable
        SSLSocketFactory ˊॱ;
        List<fut> ˋ;
        int ˋˊ;
        @Nullable
        fvj ˋॱ;
        final List<fuo> ˎ;
        ful ˏ;
        HostnameVerifier ˏॱ;
        SocketFactory ͺ;
        List<fud> ॱ;
        @Nullable
        fxe ॱˊ;
        fuf ॱˋ;
        fuj ॱˎ;
        fue ॱॱ;
        fty ॱᐝ;
        a ᐝ;
        ftx ᐝॱ;

        public b() {
            this.ˎ = new ArrayList();
            this.ʽ = new ArrayList();
            this.ˏ = new ful();
            this.ˋ = fuv.ˏ;
            this.ॱ = fuv.ॱ;
            this.ᐝ = fum.factory(fum.NONE);
            this.ʻ = ProxySelector.getDefault();
            if (this.ʻ == null) {
                this.ʻ = new fwx();
            }
            this.ॱॱ = fue.ॱ;
            this.ͺ = SocketFactory.getDefault();
            this.ˏॱ = fxc.ˊ;
            this.ॱᐝ = fty.ˋ;
            this.ᐝॱ = ftx.ˎ;
            this.ʻॱ = ftx.ˎ;
            this.ॱˋ = new fuf();
            this.ॱˎ = fuj.ˊ;
            this.ʿ = true;
            this.ʽॱ = true;
            this.ʼॱ = true;
            this.ʾ = 0;
            this.ˈ = 10000;
            this.ˊˋ = 10000;
            this.ˋˊ = 10000;
            this.ˊˊ = 0;
            this.ˉ = 200;
        }

        b(fuv o_fuv) {
            this.ˎ = new ArrayList();
            this.ʽ = new ArrayList();
            this.ˏ = o_fuv.ˎ;
            this.ˊ = o_fuv.ˋ;
            this.ˋ = o_fuv.ˊ;
            this.ॱ = o_fuv.ʽ;
            this.ˎ.addAll(o_fuv.ॱॱ);
            this.ʽ.addAll(o_fuv.ʻ);
            this.ᐝ = o_fuv.ʼ;
            this.ʻ = o_fuv.ᐝ;
            this.ॱॱ = o_fuv.ͺ;
            this.ˋॱ = o_fuv.ॱˊ;
            this.ʼ = o_fuv.ˋॱ;
            this.ͺ = o_fuv.ˊॱ;
            this.ˊॱ = o_fuv.ˏॱ;
            this.ॱˊ = o_fuv.ॱˋ;
            this.ˏॱ = o_fuv.ᐝॱ;
            this.ॱᐝ = o_fuv.ॱᐝ;
            this.ᐝॱ = o_fuv.ॱˎ;
            this.ʻॱ = o_fuv.ʻॱ;
            this.ॱˋ = o_fuv.ʾ;
            this.ॱˎ = o_fuv.ʼॱ;
            this.ʿ = o_fuv.ʿ;
            this.ʽॱ = o_fuv.ˈ;
            this.ʼॱ = o_fuv.ʽॱ;
            this.ʾ = o_fuv.ˊˊ;
            this.ˈ = o_fuv.ˊˋ;
            this.ˊˋ = o_fuv.ˊᐝ;
            this.ˋˊ = o_fuv.ˋˊ;
            this.ˊˊ = o_fuv.ˉ;
            this.ˉ = o_fuv.ˋˋ;
        }

        public b ˎ(long j, TimeUnit timeUnit) {
            this.ˈ = fvg.ˎ("timeout", j, timeUnit);
            if (this.ˉ < this.ˈ) {
                return this;
            }
            throw new IllegalArgumentException("Connection Attempt Delay (" + this.ˉ + " ms) is greater than or equal to Connect Timeout (" + this.ˈ + " ms)");
        }

        public b ˊ(long j, TimeUnit timeUnit) {
            this.ˊˋ = fvg.ˎ("timeout", j, timeUnit);
            return this;
        }

        public b ˋ(long j, TimeUnit timeUnit) {
            this.ˋˊ = fvg.ˎ("timeout", j, timeUnit);
            return this;
        }

        public b ˏ(long j, TimeUnit timeUnit) {
            this.ˊˊ = fvg.ˎ("interval", j, timeUnit);
            return this;
        }

        public b ॱ(long j, TimeUnit timeUnit) {
            this.ˉ = fvg.ˎ("connectionAttemptDelay", j, timeUnit);
            if (this.ˉ < 100 || this.ˉ > 2000) {
                throw new IllegalArgumentException("Connection Attempt Delay " + this.ˉ + "ms is out of range (" + 100 + "ms ~ " + 2000 + "ms).");
            } else if (this.ˉ < this.ˈ) {
                return this;
            } else {
                throw new IllegalArgumentException("Connection Attempt Delay (" + this.ˉ + " ms) is greater than or equal to Connect Timeout (" + this.ˈ + " ms)");
            }
        }

        public b ॱ(@Nullable Proxy proxy) {
            this.ˊ = proxy;
            return this;
        }

        public b ˋ(@Nullable ftw o_ftw) {
            this.ʼ = o_ftw;
            this.ˋॱ = null;
            return this;
        }

        public b ॱ(fuj o_fuj) {
            if (o_fuj == null) {
                throw new NullPointerException("dns == null");
            }
            this.ॱˎ = o_fuj;
            return this;
        }

        public b ॱ(SSLSocketFactory sSLSocketFactory, X509TrustManager x509TrustManager) {
            if (sSLSocketFactory == null) {
                throw new NullPointerException("sslSocketFactory == null");
            } else if (x509TrustManager == null) {
                throw new NullPointerException("trustManager == null");
            } else {
                this.ˊॱ = sSLSocketFactory;
                this.ॱˊ = fxe.ˋ(x509TrustManager);
                return this;
            }
        }

        public b ˊ(HostnameVerifier hostnameVerifier) {
            if (hostnameVerifier == null) {
                throw new NullPointerException("hostnameVerifier == null");
            }
            this.ˏॱ = hostnameVerifier;
            return this;
        }

        public b ˊ(fuf o_fuf) {
            if (o_fuf == null) {
                throw new NullPointerException("connectionPool == null");
            }
            this.ॱˋ = o_fuf;
            return this;
        }

        public b ˎ(boolean z) {
            this.ʿ = z;
            return this;
        }

        public b ॱ(boolean z) {
            this.ʽॱ = z;
            return this;
        }

        public b ˏ(boolean z) {
            this.ʼॱ = z;
            return this;
        }

        public b ˎ(ful o_ful) {
            if (o_ful == null) {
                throw new IllegalArgumentException("dispatcher == null");
            }
            this.ˏ = o_ful;
            return this;
        }

        public b ॱ(List<fut> list) {
            List arrayList = new ArrayList(list);
            if (!arrayList.contains(fut.H2_PRIOR_KNOWLEDGE) && !arrayList.contains(fut.HTTP_1_1)) {
                throw new IllegalArgumentException("protocols must contain h2_prior_knowledge or http/1.1: " + arrayList);
            } else if (arrayList.contains(fut.H2_PRIOR_KNOWLEDGE) && arrayList.size() > 1) {
                throw new IllegalArgumentException("protocols containing h2_prior_knowledge cannot use other protocols: " + arrayList);
            } else if (arrayList.contains(fut.HTTP_1_0)) {
                throw new IllegalArgumentException("protocols must not contain http/1.0: " + arrayList);
            } else if (arrayList.contains(null)) {
                throw new IllegalArgumentException("protocols must not contain null");
            } else {
                arrayList.remove(fut.SPDY_3);
                this.ˋ = Collections.unmodifiableList(arrayList);
                return this;
            }
        }

        public b ˎ(fuo o_fuo) {
            if (o_fuo == null) {
                throw new IllegalArgumentException("interceptor == null");
            }
            this.ˎ.add(o_fuo);
            return this;
        }

        public b ˋ(a aVar) {
            if (aVar == null) {
                throw new NullPointerException("eventListenerFactory == null");
            }
            this.ᐝ = aVar;
            return this;
        }

        public fuv ˋ() {
            return new fuv(this);
        }

        public ful ˋ(fut o_fut) {
            switch (o_fut) {
                case HTTP_2:
                    return new fun();
                case HTTP_1_0:
                case HTTP_1_1:
                case SPDY_3:
                    return new ful();
                default:
                    throw new IllegalArgumentException("there is no dispatcher fit for the protocol " + o_fut.toString());
            }
        }
    }

    class e implements d {
        final /* synthetic */ fuv ˊ;

        private e(fuv o_fuv) {
            this.ˊ = o_fuv;
        }

        public void ॱ(String str, int i, String str2) {
            this.ˊ.ˎ.ˊ(str, i, str2);
        }
    }

    static {
        fux.ˏ = new fux() {
            public void ˊ(fui.a aVar, String str) {
                aVar.ˏ(str);
            }

            public void ˋ(fui.a aVar, String str, String str2) {
                aVar.ॱ(str, str2);
            }

            public boolean ˊ(fuf o_fuf, RealConnection realConnection) {
                return o_fuf.ˏ(realConnection);
            }

            public RealConnection ˏ(fuf o_fuf, ftt o_ftt, StreamAllocation streamAllocation, Route route) {
                return o_fuf.ॱ(o_ftt, streamAllocation, route);
            }

            public boolean ˊ(ftt o_ftt, ftt o_ftt2) {
                return o_ftt.ˏ(o_ftt2);
            }

            public Socket ˊ(fuv o_fuv, fuf o_fuf, ftt o_ftt, StreamAllocation streamAllocation) {
                return o_fuf.ˎ(o_ftt, streamAllocation, o_fuv.ˈ().ˊ());
            }

            public void ॱ(fuf o_fuf, RealConnection realConnection) {
                o_fuf.ˎ(realConnection);
            }

            public fvn ˎ(fuf o_fuf) {
                return o_fuf.ˏ;
            }

            public int ˎ(fvb.d dVar) {
                return dVar.ॱ;
            }

            public void ˋ(fud o_fud, SSLSocket sSLSocket, boolean z) {
                o_fud.ˏ(sSLSocket, z);
            }

            @Nullable
            public IOException ˋ(ftz o_ftz, @Nullable IOException iOException) {
                return ((RealCall) o_ftz).timeoutExit(iOException);
            }
        };
    }

    public fuv() {
        this(new b());
    }

    fuv(b bVar) {
        this.ˎˎ = new e();
        this.ˎ = bVar.ˏ;
        this.ˋ = bVar.ˊ;
        this.ˊ = bVar.ˋ;
        this.ʽ = bVar.ॱ;
        this.ॱॱ = fvg.ˏ(bVar.ˎ);
        this.ʻ = fvg.ˏ(bVar.ʽ);
        this.ʼ = bVar.ᐝ;
        this.ᐝ = bVar.ʻ;
        this.ͺ = bVar.ॱॱ;
        this.ˋॱ = bVar.ʼ;
        this.ॱˊ = bVar.ˋॱ;
        this.ˊॱ = bVar.ͺ;
        Object obj = null;
        for (fud o_fud : this.ʽ) {
            Object obj2;
            if (obj != null || o_fud.ˎ()) {
                obj2 = 1;
            } else {
                obj2 = null;
            }
            obj = obj2;
        }
        if (bVar.ˊॱ != null || obj == null) {
            this.ˏॱ = bVar.ˊॱ;
            this.ॱˋ = bVar.ॱˊ;
        } else {
            X509TrustManager ॱ = fvg.ॱ();
            this.ˏॱ = ˋ(ॱ);
            this.ॱˋ = fxe.ˋ(ॱ);
        }
        if (this.ˏॱ != null) {
            fwy.ˋ().ˊ(this.ˏॱ);
        }
        this.ᐝॱ = bVar.ˏॱ;
        this.ॱᐝ = bVar.ॱᐝ.ॱ(this.ॱˋ);
        this.ॱˎ = bVar.ᐝॱ;
        this.ʻॱ = bVar.ʻॱ;
        this.ʾ = bVar.ॱˋ;
        this.ʼॱ = bVar.ॱˎ;
        this.ʿ = bVar.ʿ;
        this.ˈ = bVar.ʽॱ;
        this.ʽॱ = bVar.ʼॱ;
        this.ˊˊ = bVar.ʾ;
        this.ˊˋ = bVar.ˈ;
        this.ˊᐝ = bVar.ˊˋ;
        this.ˋˊ = bVar.ˋˊ;
        this.ˉ = bVar.ˊˊ;
        if (this.ॱॱ.contains(null)) {
            throw new IllegalStateException("Null interceptor: " + this.ॱॱ);
        } else if (this.ʻ.contains(null)) {
            throw new IllegalStateException("Null network interceptor: " + this.ʻ);
        } else {
            this.ʾ.ˋ(this.ˎˎ);
            this.ˋˋ = bVar.ˉ;
        }
    }

    private static SSLSocketFactory ˋ(X509TrustManager x509TrustManager) {
        try {
            SSLContext ॱ = fwy.ˋ().ॱ();
            ॱ.init(null, new TrustManager[]{x509TrustManager}, null);
            return ॱ.getSocketFactory();
        } catch (Exception e) {
            throw fvg.ॱ("No System TLS", e);
        }
    }

    public int ˎ() {
        return this.ˊˊ;
    }

    public int ˋ() {
        return this.ˊˋ;
    }

    public int ˏ() {
        return this.ˊᐝ;
    }

    public int ॱ() {
        return this.ˋˊ;
    }

    public int ˊ() {
        return this.ˉ;
    }

    @Nullable
    public Proxy ʽ() {
        return this.ˋ;
    }

    public ProxySelector ᐝ() {
        return this.ᐝ;
    }

    public fue ॱॱ() {
        return this.ͺ;
    }

    public fvj ʻ() {
        return this.ˋॱ != null ? this.ˋॱ.ˎ : this.ॱˊ;
    }

    public fuj ʼ() {
        return this.ʼॱ;
    }

    public SocketFactory ˋॱ() {
        return this.ˊॱ;
    }

    public SSLSocketFactory ॱˊ() {
        return this.ˏॱ;
    }

    public HostnameVerifier ͺ() {
        return this.ᐝॱ;
    }

    public fty ˏॱ() {
        return this.ॱᐝ;
    }

    public ftx ˊॱ() {
        return this.ʻॱ;
    }

    public ftx ॱˋ() {
        return this.ॱˎ;
    }

    public fuf ʻॱ() {
        return this.ʾ;
    }

    public boolean ॱᐝ() {
        return this.ʿ;
    }

    public boolean ॱˎ() {
        return this.ˈ;
    }

    public boolean ᐝॱ() {
        return this.ʽॱ;
    }

    public ful ˈ() {
        return this.ˎ;
    }

    public void ˋ(String str, int i, String str2) {
        this.ˎ.ˎ(str, i, str2);
    }

    public List<fut> ʽॱ() {
        return this.ˊ;
    }

    public List<fud> ʿ() {
        return this.ʽ;
    }

    public int ʼॱ() {
        return this.ˋˋ;
    }

    public List<fuo> ʾ() {
        return this.ॱॱ;
    }

    public List<fuo> ˊᐝ() {
        return this.ʻ;
    }

    public a ˋˊ() {
        return this.ʼ;
    }

    public ftz ˎ(fus o_fus) {
        return RealCall.newRealCall(this, o_fus, false);
    }

    public int ˎ(String str, int i, String str2) {
        return this.ʾ.ˎ(str, i, str2);
    }

    public boolean ˏ(String str, int i, String str2) {
        return this.ʾ.ॱ(str, i, str2);
    }

    public b ˉ() {
        return new b(this);
    }

    public static String ˊˋ() {
        return fvc.ˋ();
    }
}
